import React from 'react'
import store from '../app/store';
import {add, sub, asyncAddAction} from '../app/features/countSlice';
import {add as ad, sub as su} from '../app/features/zanSlice';
export default function ReduxCom() {
  return (
    <div>
      <h2>{store.getState().count}</h2>
      <button onClick={() => {
        store.dispatch(add(5));
      }}>++</button>
      <button onClick={() => {
        store.dispatch(sub(10));
      }}>--</button>
      <button onClick={() => {
        store.dispatch(asyncAddAction(100));
      }}>1秒之后+1</button>
      <hr />
      <h2>当前的点赞数: {store.getState().zan.value}</h2>
      <button onClick={() => {
        store.dispatch(ad(10));
      }}>点赞</button>
    </div>
  )
}
